package org.example.thread.testSequence;

import java.util.concurrent.*;

/**
 * @author liyishan
 * @date 2024/7/16 15:04
 * @apiNote
 */

public class TestSequence02 {
    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(() -> System.out.println("线程1"), "线程1");
        Thread t2 = new Thread(() -> System.out.println("线程2"), "线程2");
        Thread t3 = new Thread(() -> System.out.println("线程3"));
        ExecutorService executor = Executors.newSingleThreadExecutor();


        // 将线程依次加入到线程池中
        executor.submit(t1);
        executor.submit(t2);
        executor.submit(t3);

        // 及时将线程池关闭
        executor.shutdown();


    }
}
